import React, { useState } from 'react'
import { useDispatch, useSelector } from 'react-redux';

import { addComment, removeComment, updateComment } from '../../store/comments';

function index() {
    const [content, setContent] = useState('');
    const dispatch = useDispatch();

    const handleAddComment = () => {
        if (content.trim()) {
            dispatch(addComment({ content, author: 'User', timestamp: '' }));
            setContent('');
        }
    };

   

    return (
        <div>
            <div>
                <textarea
                    style={{
                        width: '100%',
                        height: '10vh'
                    }}
                    value={content}
                    onChange={(e) => setContent(e.target.value)}
                    placeholder="请输入你要评论的信息"
                />
                <button onClick={handleAddComment}>添加评论</button>
            </div>
        </div>
    )
}

export default index